package com.qhg.saas_server.controller;


import com.qhg.saas_server.annotation.Mylog;
import com.qhg.saas_server.empty.Result;
import com.qhg.saas_server.pojo.Upload;
import com.qhg.saas_server.pojo.dto.UpLoadDto;
import com.qhg.saas_server.service.UpLoadService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "上传信息管理")
@RestController
@Slf4j
@RequestMapping("/upload")
@CrossOrigin
public class UpLoadController {

    @Autowired
    UpLoadService upLoadService;

    @ApiOperation("根据条件获取上传信息管理<分页获取>")
    @PostMapping
    public Result getUploadByCondition(@RequestBody UpLoadDto upLoadDto){

        return upLoadService.getUploadByCondition(upLoadDto);

    }

    @ApiOperation("添加上传信息")
    @PostMapping("/add")
    @Mylog("添加上传信息")
    public Result addUpload(@RequestBody Upload upload){

        upLoadService.addUpload(upload);
        return Result.success("添加成功");
    }

    @ApiOperation("删除上传信息")
    @DeleteMapping("/{uploadId}")
    @Mylog("删除上传信息")
    public Result deleteUpload(@PathVariable("uploadId") Integer uploadId){

        upLoadService.deleteUpload(uploadId);
        return Result.success("删除成功");

    }


}
